<?php
/**
 * CampaignEx
 *
 * PHP version 5
 *
 * @category Class
 * @package  AmazonAdvertisingApi
 * @author   vv_guo
 * @link    https://gitee.com/HuaLiLiDeDiDiao/amazon-advertising-api
 */

/**
 * Amazon Ads API - Sponsored Products
 *
 * Use the Amazon Ads API for Sponsored Products for campaign, ad group, keyword, negative keyword, and product ad management operations. For more information about Sponsored Products, see the [Sponsored Products Support Center](https://advertising.amazon.com/help?entityId=ENTITY3CWETCZD9HEG2#GWGFKPEWVWG2CLUJ). For onboarding information, see the [account setup](guides/onboarding/overview) topic.<br/> <br/> **Note**: This contract contains endpoints with upcoming planned deprecations. For more information on the latest versions and migration details, see [Deprecations](release-notes/deprecations).<br/> <br/>
 *
 * OpenAPI spec version: 2.0
 * 
 * Generated by:https://gitee.com/HuaLiLiDeDiDiao/amazon-advertising-api.git
 * AmazonAdvertisingApi Codegen version: 3.0.51
 */
/**
 * NOTE: This class is auto generated by the AmazonAdvertisingApi code generator program.
 *https://gitee.com/HuaLiLiDeDiDiao/amazon-advertising-api
 * Do not edit the class manually.
 */

namespace AmazonAdvertisingApi\Model;

use \ArrayAccess;
use \AmazonAdvertisingApi\ObjectSerializer;

/**
 * CampaignEx Class Doc Comment
 *
 * @category Class
 * @package  AmazonAdvertisingApi
 * @author   vv_guo
 * @link    https://gitee.com/HuaLiLiDeDiDiao/amazon-advertising-api
 */
class CampaignEx implements ModelInterface, ArrayAccess
{
    const DISCRIMINATOR = null;

    /**
      * The original name of the model.
      *
      * @var string
      */
    protected static $AmazonAdvertisingApiModelName = 'CampaignEx';

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $AmazonAdvertisingApiTypes = [
        'portfolio_id' => 'float',
        'campaign_id' => 'float',
        'tags' => '\AmazonAdvertisingApi\Model\CampaignTags',
        'name' => 'string',
        'campaign_type' => 'string',
        'targeting_type' => 'string',
        'state' => '\AmazonAdvertisingApi\Model\State',
        'daily_budget' => 'float',
        'start_date' => 'string',
        'end_date' => 'string',
        'premium_bid_adjustment' => 'bool',
        'bidding' => '\AmazonAdvertisingApi\Model\Bidding',
        'creation_date' => 'float',
        'last_updated_date' => 'float',
        'serving_status' => 'string'
    ];

    /**
      * Array of property to format mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $AmazonAdvertisingApiFormats = [
        'portfolio_id' => null,
        'campaign_id' => null,
        'tags' => null,
        'name' => null,
        'campaign_type' => null,
        'targeting_type' => null,
        'state' => null,
        'daily_budget' => 'float',
        'start_date' => null,
        'end_date' => null,
        'premium_bid_adjustment' => null,
        'bidding' => null,
        'creation_date' => null,
        'last_updated_date' => null,
        'serving_status' => null
    ];

    /**
     * Array of property to type mappings. Used for (de)serialization
     *
     * @return array
     */
    public static function AmazonAdvertisingApiTypes()
    {
        return self::$AmazonAdvertisingApiTypes;
    }

    /**
     * Array of property to format mappings. Used for (de)serialization
     *
     * @return array
     */
    public static function AmazonAdvertisingApiFormats()
    {
        return self::$AmazonAdvertisingApiFormats;
    }

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'portfolio_id' => 'portfolioId',
        'campaign_id' => 'campaignId',
        'tags' => 'tags',
        'name' => 'name',
        'campaign_type' => 'campaignType',
        'targeting_type' => 'targetingType',
        'state' => 'state',
        'daily_budget' => 'dailyBudget',
        'start_date' => 'startDate',
        'end_date' => 'endDate',
        'premium_bid_adjustment' => 'premiumBidAdjustment',
        'bidding' => 'bidding',
        'creation_date' => 'creationDate',
        'last_updated_date' => 'lastUpdatedDate',
        'serving_status' => 'servingStatus'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'portfolio_id' => 'setPortfolioId',
        'campaign_id' => 'setCampaignId',
        'tags' => 'setTags',
        'name' => 'setName',
        'campaign_type' => 'setCampaignType',
        'targeting_type' => 'setTargetingType',
        'state' => 'setState',
        'daily_budget' => 'setDailyBudget',
        'start_date' => 'setStartDate',
        'end_date' => 'setEndDate',
        'premium_bid_adjustment' => 'setPremiumBidAdjustment',
        'bidding' => 'setBidding',
        'creation_date' => 'setCreationDate',
        'last_updated_date' => 'setLastUpdatedDate',
        'serving_status' => 'setServingStatus'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'portfolio_id' => 'getPortfolioId',
        'campaign_id' => 'getCampaignId',
        'tags' => 'getTags',
        'name' => 'getName',
        'campaign_type' => 'getCampaignType',
        'targeting_type' => 'getTargetingType',
        'state' => 'getState',
        'daily_budget' => 'getDailyBudget',
        'start_date' => 'getStartDate',
        'end_date' => 'getEndDate',
        'premium_bid_adjustment' => 'getPremiumBidAdjustment',
        'bidding' => 'getBidding',
        'creation_date' => 'getCreationDate',
        'last_updated_date' => 'getLastUpdatedDate',
        'serving_status' => 'getServingStatus'
    ];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @return array
     */
    public static function attributeMap()
    {
        return self::$attributeMap;
    }

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @return array
     */
    public static function setters()
    {
        return self::$setters;
    }

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @return array
     */
    public static function getters()
    {
        return self::$getters;
    }

    /**
     * The original name of the model.
     *
     * @return string
     */
    public function getModelName()
    {
        return self::$AmazonAdvertisingApiModelName;
    }

    const CAMPAIGN_TYPE_SPONSORED_PRODUCTS = 'sponsoredProducts';
    const TARGETING_TYPE_MANUAL = 'manual';
    const TARGETING_TYPE_AUTO = 'auto';
    const SERVING_STATUS_CAMPAIGN_ARCHIVED = 'CAMPAIGN_ARCHIVED';
    const SERVING_STATUS_CAMPAIGN_PAUSED = 'CAMPAIGN_PAUSED';
    const SERVING_STATUS_CAMPAIGN_STATUS_ENABLED = 'CAMPAIGN_STATUS_ENABLED';
    const SERVING_STATUS_ADVERTISER_PAYMENT_FAILED = 'ADVERTISER_PAYMENT_FAILED';
    const SERVING_STATUS_ADVERTISER_PAYMENT_FAILURE = 'ADVERTISER_PAYMENT_FAILURE';
    const SERVING_STATUS_CAMPAIGN_OUT_OF_BUDGET = 'CAMPAIGN_OUT_OF_BUDGET';
    const SERVING_STATUS_PENDING_START_DATE = 'PENDING_START_DATE';
    const SERVING_STATUS_CAMPAIGN_INCOMPLETE = 'CAMPAIGN_INCOMPLETE';
    const SERVING_STATUS_ENDED = 'ENDED';

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getCampaignTypeAllowableValues()
    {
        return [
            self::CAMPAIGN_TYPE_SPONSORED_PRODUCTS,
        ];
    }
    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getTargetingTypeAllowableValues()
    {
        return [
            self::TARGETING_TYPE_MANUAL,
            self::TARGETING_TYPE_AUTO,
        ];
    }
    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getServingStatusAllowableValues()
    {
        return [
            self::SERVING_STATUS_CAMPAIGN_ARCHIVED,
            self::SERVING_STATUS_CAMPAIGN_PAUSED,
            self::SERVING_STATUS_CAMPAIGN_STATUS_ENABLED,
            self::SERVING_STATUS_ADVERTISER_PAYMENT_FAILED,
            self::SERVING_STATUS_ADVERTISER_PAYMENT_FAILURE,
            self::SERVING_STATUS_CAMPAIGN_OUT_OF_BUDGET,
            self::SERVING_STATUS_PENDING_START_DATE,
            self::SERVING_STATUS_CAMPAIGN_INCOMPLETE,
            self::SERVING_STATUS_ENDED,
        ];
    }

    /**
     * Associative array for storing property values
     *
     * @var mixed[]
     */
    protected $container = [];

    /**
     * Constructor
     *
     * @param mixed[] $data Associated array of property values
     *                      initializing the model
     */
    public function __construct(array $data = null)
    {
        $this->container['portfolio_id'] = isset($data['portfolio_id']) ? $data['portfolio_id'] : null;
        $this->container['campaign_id'] = isset($data['campaign_id']) ? $data['campaign_id'] : null;
        $this->container['tags'] = isset($data['tags']) ? $data['tags'] : null;
        $this->container['name'] = isset($data['name']) ? $data['name'] : null;
        $this->container['campaign_type'] = isset($data['campaign_type']) ? $data['campaign_type'] : null;
        $this->container['targeting_type'] = isset($data['targeting_type']) ? $data['targeting_type'] : null;
        $this->container['state'] = isset($data['state']) ? $data['state'] : null;
        $this->container['daily_budget'] = isset($data['daily_budget']) ? $data['daily_budget'] : null;
        $this->container['start_date'] = isset($data['start_date']) ? $data['start_date'] : null;
        $this->container['end_date'] = isset($data['end_date']) ? $data['end_date'] : null;
        $this->container['premium_bid_adjustment'] = isset($data['premium_bid_adjustment']) ? $data['premium_bid_adjustment'] : null;
        $this->container['bidding'] = isset($data['bidding']) ? $data['bidding'] : null;
        $this->container['creation_date'] = isset($data['creation_date']) ? $data['creation_date'] : null;
        $this->container['last_updated_date'] = isset($data['last_updated_date']) ? $data['last_updated_date'] : null;
        $this->container['serving_status'] = isset($data['serving_status']) ? $data['serving_status'] : null;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties()
    {
        $invalidProperties = [];

        $allowedValues = $this->getCampaignTypeAllowableValues();
        if (!is_null($this->container['campaign_type']) && !in_array($this->container['campaign_type'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value for 'campaign_type', must be one of '%s'",
                implode("', '", $allowedValues)
            );
        }

        $allowedValues = $this->getTargetingTypeAllowableValues();
        if (!is_null($this->container['targeting_type']) && !in_array($this->container['targeting_type'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value for 'targeting_type', must be one of '%s'",
                implode("', '", $allowedValues)
            );
        }

        $allowedValues = $this->getServingStatusAllowableValues();
        if (!is_null($this->container['serving_status']) && !in_array($this->container['serving_status'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value for 'serving_status', must be one of '%s'",
                implode("', '", $allowedValues)
            );
        }

        return $invalidProperties;
    }

    /**
     * Validate all the properties in the model
     * return true if all passed
     *
     * @return bool True if all properties are valid
     */
    public function valid()
    {
        return count($this->listInvalidProperties()) === 0;
    }


    /**
     * Gets portfolio_id
     *
     * @return float
     */
    public function getPortfolioId()
    {
        return $this->container['portfolio_id'];
    }

    /**
     * Sets portfolio_id
     *
     * @param float $portfolio_id The identifier of an existing portfolio to which the campaign is associated.
     *
     * @return $this
     */
    public function setPortfolioId($portfolio_id)
    {
        $this->container['portfolio_id'] = $portfolio_id;

        return $this;
    }

    /**
     * Gets campaign_id
     *
     * @return float
     */
    public function getCampaignId()
    {
        return $this->container['campaign_id'];
    }

    /**
     * Sets campaign_id
     *
     * @param float $campaign_id The identifier of the campaign.
     *
     * @return $this
     */
    public function setCampaignId($campaign_id)
    {
        $this->container['campaign_id'] = $campaign_id;

        return $this;
    }

    /**
     * Gets tags
     *
     * @return \AmazonAdvertisingApi\Model\CampaignTags
     */
    public function getTags()
    {
        return $this->container['tags'];
    }

    /**
     * Sets tags
     *
     * @param \AmazonAdvertisingApi\Model\CampaignTags $tags tags
     *
     * @return $this
     */
    public function setTags($tags)
    {
        $this->container['tags'] = $tags;

        return $this;
    }

    /**
     * Gets name
     *
     * @return string
     */
    public function getName()
    {
        return $this->container['name'];
    }

    /**
     * Sets name
     *
     * @param string $name The name of the campaign.
     *
     * @return $this
     */
    public function setName($name)
    {
        $this->container['name'] = $name;

        return $this;
    }

    /**
     * Gets campaign_type
     *
     * @return string
     */
    public function getCampaignType()
    {
        return $this->container['campaign_type'];
    }

    /**
     * Sets campaign_type
     *
     * @param string $campaign_type The advertising product managed by this campaign.
     *
     * @return $this
     */
    public function setCampaignType($campaign_type)
    {
        $allowedValues = $this->getCampaignTypeAllowableValues();
        if (!is_null($campaign_type) && !in_array($campaign_type, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'campaign_type', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['campaign_type'] = $campaign_type;

        return $this;
    }

    /**
     * Gets targeting_type
     *
     * @return string
     */
    public function getTargetingType()
    {
        return $this->container['targeting_type'];
    }

    /**
     * Sets targeting_type
     *
     * @param string $targeting_type The type of targeting of the campaign.
     *
     * @return $this
     */
    public function setTargetingType($targeting_type)
    {
        $allowedValues = $this->getTargetingTypeAllowableValues();
        if (!is_null($targeting_type) && !in_array($targeting_type, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'targeting_type', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['targeting_type'] = $targeting_type;

        return $this;
    }

    /**
     * Gets state
     *
     * @return \AmazonAdvertisingApi\Model\State
     */
    public function getState()
    {
        return $this->container['state'];
    }

    /**
     * Sets state
     *
     * @param \AmazonAdvertisingApi\Model\State $state state
     *
     * @return $this
     */
    public function setState($state)
    {
        $this->container['state'] = $state;

        return $this;
    }

    /**
     * Gets daily_budget
     *
     * @return float
     */
    public function getDailyBudget()
    {
        return $this->container['daily_budget'];
    }

    /**
     * Sets daily_budget
     *
     * @param float $daily_budget The daily budget of the campaign.
     *
     * @return $this
     */
    public function setDailyBudget($daily_budget)
    {
        $this->container['daily_budget'] = $daily_budget;

        return $this;
    }

    /**
     * Gets start_date
     *
     * @return string
     */
    public function getStartDate()
    {
        return $this->container['start_date'];
    }

    /**
     * Sets start_date
     *
     * @param string $start_date The starting date of the campaign. The format of the date is YYYYMMDD.
     *
     * @return $this
     */
    public function setStartDate($start_date)
    {
        $this->container['start_date'] = $start_date;

        return $this;
    }

    /**
     * Gets end_date
     *
     * @return string
     */
    public function getEndDate()
    {
        return $this->container['end_date'];
    }

    /**
     * Sets end_date
     *
     * @param string $end_date The ending date of the campaign to stop running. The format of the date is YYYYMMDD.
     *
     * @return $this
     */
    public function setEndDate($end_date)
    {
        $this->container['end_date'] = $end_date;

        return $this;
    }

    /**
     * Gets premium_bid_adjustment
     *
     * @return bool
     */
    public function getPremiumBidAdjustment()
    {
        return $this->container['premium_bid_adjustment'];
    }

    /**
     * Sets premium_bid_adjustment
     *
     * @param bool $premium_bid_adjustment If set to true, Amazon increases the default bid for ads that are eligible to appear in this placement. See developer notes for more information.
     *
     * @return $this
     */
    public function setPremiumBidAdjustment($premium_bid_adjustment)
    {
        $this->container['premium_bid_adjustment'] = $premium_bid_adjustment;

        return $this;
    }

    /**
     * Gets bidding
     *
     * @return \AmazonAdvertisingApi\Model\Bidding
     */
    public function getBidding()
    {
        return $this->container['bidding'];
    }

    /**
     * Sets bidding
     *
     * @param \AmazonAdvertisingApi\Model\Bidding $bidding bidding
     *
     * @return $this
     */
    public function setBidding($bidding)
    {
        $this->container['bidding'] = $bidding;

        return $this;
    }

    /**
     * Gets creation_date
     *
     * @return float
     */
    public function getCreationDate()
    {
        return $this->container['creation_date'];
    }

    /**
     * Sets creation_date
     *
     * @param float $creation_date The creation date of the campaign, in epoch time.
     *
     * @return $this
     */
    public function setCreationDate($creation_date)
    {
        $this->container['creation_date'] = $creation_date;

        return $this;
    }

    /**
     * Gets last_updated_date
     *
     * @return float
     */
    public function getLastUpdatedDate()
    {
        return $this->container['last_updated_date'];
    }

    /**
     * Sets last_updated_date
     *
     * @param float $last_updated_date The date that any value associated with the campaign was last changed, in epoch time.
     *
     * @return $this
     */
    public function setLastUpdatedDate($last_updated_date)
    {
        $this->container['last_updated_date'] = $last_updated_date;

        return $this;
    }

    /**
     * Gets serving_status
     *
     * @return string
     */
    public function getServingStatus()
    {
        return $this->container['serving_status'];
    }

    /**
     * Sets serving_status
     *
     * @param string $serving_status The computed status of the campaign. See developer notes for more information.
     *
     * @return $this
     */
    public function setServingStatus($serving_status)
    {
        $allowedValues = $this->getServingStatusAllowableValues();
        if (!is_null($serving_status) && !in_array($serving_status, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'serving_status', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['serving_status'] = $serving_status;

        return $this;
    }
    /**
     * Returns true if offset exists. False otherwise.
     *
     * @param integer $offset Offset
     *
     * @return boolean
     */
    #[\ReturnTypeWillChange]
    public function offsetExists($offset)
    {
        return isset($this->container[$offset]);
    }

    /**
     * Gets offset.
     *
     * @param integer $offset Offset
     *
     * @return mixed
     */
    #[\ReturnTypeWillChange]
    public function offsetGet($offset)
    {
        return isset($this->container[$offset]) ? $this->container[$offset] : null;
    }

    /**
     * Sets value based on offset.
     *
     * @param integer $offset Offset
     * @param mixed   $value  Value to be set
     *
     * @return void
     */
    #[\ReturnTypeWillChange]
    public function offsetSet($offset, $value)
    {
        if (is_null($offset)) {
            $this->container[] = $value;
        } else {
            $this->container[$offset] = $value;
        }
    }

    /**
     * Unsets offset.
     *
     * @param integer $offset Offset
     *
     * @return void
     */
    #[\ReturnTypeWillChange]
    public function offsetUnset($offset)
    {
        unset($this->container[$offset]);
    }

    /**
     * Gets the string presentation of the object
     *
     * @return string
     */
    public function __toString()
    {
        if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
            return json_encode(
                ObjectSerializer::sanitizeForSerialization($this),
                JSON_PRETTY_PRINT
            );
        }

        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
    }
}
